*----------------------------------------------------------------------------------------------------------	* 
* RESEARCHERS:		Emtiaz Hritan, Tim Bruckner									   							*
* PROGRAMMED BY:	Emtiaz Hritan																			*
* DESCRIPTION:      The Politics of Birth: How Local Representation Shapes Maternal-Infant Outcomes				 						 	*
* CREATED:			Oct. 14, 2025																		   	*
* LAST MODIFIED:	Jan. 27, 2026													       					*
*----------------------------------------------------------------------------------------------------------	*

clear all
set more off
* Set local paths
* Set this local datapath equal to the folder location for data
	local datapath "C:\Users\name\Replication Files Politics of Birth\Data"
* Set this local outputpath equal to the folder location for outcome like tables
	local outputpath "C:\Users\name\Replication Files Politics of Birth\Outcome"
	
	
* Install necessary packages
ssc install reghdfe
ssc install ftools
ssc install grstyle, replace
ssc install palettes, replace
ssc install colrspace, replace
ssc install ppmlhdfe, replace 
ssc install jwdid, replace 
ssc install csdid, replace 
ssc install drdid, replace 
ssc install did_imputation, replace
ssc install frause, replace
frause mpdta.dta, clear
ssc install hdfe, replace 
ssc install event_plot, replace
ssc install addplot, replace

****************************************************************************************
** Table 4: Impact of the First Black Candidate Win on Overall Perinatal Health Outcomes
****************************************************************************************

clear all 
use "`datapath'\final.dta"

* First treated year = election year + 1 (1-yr induction)
cap drop first_treat
gen first_treat = year_black + 1 if !missing(year_black)
replace first_treat = 0 if missing(first_treat)   // 0 = never-treated

* Let's drop counties with low births and low NH Black births
drop if births_all < 100
drop if births_NHB < 100	

* Panel id + time
xtset county_fips year

                        
*************Callaway and Sant'Anna (2021)*********************


*Not yet treated 
csdid imr, ivar(county_fips) time(year) gvar(first_treat) notyet 
estat all

csdid ptb_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all


csdid vptb_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid eptb_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid lbw_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid vlbw_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid csection_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid periviable_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid births_gestation_all, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid births_previsit_all, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid infant_mortality_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all





*************Callaway and Sant'Anna (2021)*********************


*Never treated 
csdid imr, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid ptb_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid vptb_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid eptb_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid lbw_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid vlbw_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid csection_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid periviable_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid births_gestation_all, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid births_previsit_all, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid infant_mortality_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all


* Using did_imputation package based on Borusyak, Kirill, Xavier Jaravel, and Jann Spiess (2023). "Revisiting Event Study Designs: Robust and Efficient Estimation," Working paper.
cap drop Ei
gen Ei = first_treat
replace Ei = . if Ei==0

* BJS Event Study Graphs
did_imputation imr county_fips year Ei, autosample

did_imputation ptb_rate county_fips year Ei, autosample

did_imputation vptb_rate county_fips year Ei, autosample

did_imputation eptb_rate county_fips year Ei, autosample

did_imputation lbw_rate county_fips year Ei, autosample

did_imputation vlbw_rate county_fips year Ei, autosample

did_imputation csection_rate county_fips year Ei, autosample

did_imputation periviable_rate county_fips year Ei, autosample

did_imputation births_gestation_all county_fips year Ei, autosample

did_imputation births_previsit_all county_fips year Ei, autosample

did_imputation infant_mortality_rate county_fips year Ei, autosample



*************************JWDID (Not Yet)

****I use jwdid package to implmemnt extended two-way Mundlak (ETWM) regression of "Wooldridge, Jeffrey. 2021.  Two-Way Fixed Effects, the Two-Way Mundlak Regression, and Differences-in-Differences estimators. Working paper."
*Estimation of ATTGTs without controls using not-yet treated groups
jwdid imr, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid ptb_rate, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid vptb_rate, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid eptb_rate, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid lbw_rate, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid vlbw_rate, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid csection_rate, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid periviable_rate, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid births_gestation_all, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid births_previsit_all, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid infant_mortality_rate, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple


*********************JWDID (Never)




****I use jwdid package to implmemnt extended two-way Mundlak (ETWM) regression of "Wooldridge, Jeffrey. 2021.  Two-Way Fixed Effects, the Two-Way Mundlak Regression, and Differences-in-Differences estimators. Working paper."
*Estimation of ATTGTs without controls using not-yet treated groups
jwdid imr, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple

jwdid ptb_rate, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid vptb_rate, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid eptb_rate, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid lbw_rate, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid vlbw_rate, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple

jwdid csection_rate, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid periviable_rate, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid births_gestation_all, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid births_previsit_all, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid infant_mortality_rate, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple



***********************************
**             End                *
***********************************













**************************************************************************************************************
** Table 5: Impact of the First Black Candidate Win on Perinatal Health Outcomes Non-Hispanic Black Mothers **
**************************************************************************************************************

clear all 
use "`datapath'\final.dta"

* First treated year = election year + 1 (1-yr induction)
cap drop first_treat
gen first_treat = year_black + 1 if !missing(year_black)
replace first_treat = 0 if missing(first_treat)   // 0 = never-treated

* Let's drop counties with low births and low NH Black births
drop if births_all < 100
drop if births_NHB < 100	

* Panel id + time
xtset county_fips year

                        
*************Callaway and Sant'Anna (2021)*********************


*Not yet treated 
csdid imr_NHB, ivar(county_fips) time(year) gvar(first_treat) notyet 
estat all

csdid ptb_rate_NHB, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all


csdid vptb_rate_NHB, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid eptb_rate_NHB, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid lbw_rate_NHB, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid vlbw_rate_NHB, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid csection_rate_NHB, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid periviable_rate_NHB, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid births_gestation_NHB, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid births_previsit_NHB, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all

csdid infant_mortality_NHB, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all





*************Callaway and Sant'Anna (2021)*********************


*Never treated 
csdid imr_NHB, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid ptb_rate_NHB, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid vptb_rate_NHB, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid eptb_rate_NHB, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid lbw_rate_NHB, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid vlbw_rate_NHB, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid csection_rate_NHB, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid periviable_rate_NHB, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid births_gestation_NHB, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid births_previsit_NHB, ivar(county_fips) time(year) gvar(first_treat) 
estat all

csdid infant_mortality_NHB, ivar(county_fips) time(year) gvar(first_treat) 
estat all


* Using did_imputation package based on Borusyak, Kirill, Xavier Jaravel, and Jann Spiess (2023). "Revisiting Event Study Designs: Robust and Efficient Estimation," Working paper.
cap drop Ei
gen Ei = first_treat
replace Ei = . if Ei==0

* BJS Event Study Graphs
did_imputation imr_NHB county_fips year Ei, autosample

did_imputation ptb_rate_NHB county_fips year Ei, autosample

did_imputation vptb_rate_NHB county_fips year Ei, autosample

did_imputation eptb_rate_NHB county_fips year Ei, autosample

did_imputation lbw_rate_NHB county_fips year Ei, autosample

did_imputation vlbw_rate_NHB county_fips year Ei, autosample

did_imputation csection_rate_NHB county_fips year Ei, autosample

did_imputation periviable_rate_NHB county_fips year Ei, autosample

did_imputation births_gestation_NHB county_fips year Ei, autosample

did_imputation births_previsit_NHB county_fips year Ei, autosample

did_imputation infant_mortality_NHB county_fips year Ei, autosample



*************************JWDID (Not Yet)

****I use jwdid package to implmemnt extended two-way Mundlak (ETWM) regression of "Wooldridge, Jeffrey. 2021.  Two-Way Fixed Effects, the Two-Way Mundlak Regression, and Differences-in-Differences estimators. Working paper."
*Estimation of ATTGTs without controls using not-yet treated groups
jwdid imr_NHB, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid ptb_rate_NHB, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid vptb_rate_NHB, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid eptb_rate_NHB, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid lbw_rate_NHB, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid vlbw_rate_NHB, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid csection_rate_NHB, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid periviable_rate_NHB, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid births_gestation_NHB, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid births_previsit_NHB, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple

jwdid infant_mortality_NHB, ivar(county_fips) tvar(year) gvar(first_treat) 
estat simple


*********************JWDID (Never)




****I use jwdid package to implmemnt extended two-way Mundlak (ETWM) regression of "Wooldridge, Jeffrey. 2021.  Two-Way Fixed Effects, the Two-Way Mundlak Regression, and Differences-in-Differences estimators. Working paper."
*Estimation of ATTGTs without controls using not-yet treated groups
jwdid imr_NHB, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple

jwdid ptb_rate_NHB, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid vptb_rate_NHB, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid eptb_rate_NHB, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid lbw_rate_NHB, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid vlbw_rate_NHB, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple

jwdid csection_rate_NHB, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid periviable_rate_NHB, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid births_gestation_NHB, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid births_previsit_NHB, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple


jwdid infant_mortality_NHB, ivar(county_fips) tvar(year) gvar(first_treat) never 
estat simple



***********************************
**             End                *
***********************************




